package cn.com.lms.business.learning.web;

import cn.com.lms.business.course.service.FbCourseInfoService;
import cn.com.lms.business.learning.persistence.entity.vo.UserLearningListVo;
import cn.com.lms.business.learning.persistence.entity.vo.UserLearningPlanVo;
import cn.com.lms.business.learning.service.LearningPlanService;
import com.bnzj.core.rest.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/*
 * @author liuwei
 * @date 2020/3/23 15:42
 * @desc APP学习计划API
 */
@Tag(name = "学习计划相关", description = "APP学习计划")
@RequestMapping("/app/learning")
@RestController
public class LearningPlanAppController {

    @Autowired
    private LearningPlanService learningPlanService;


    @Operation(description = "学习计划列表",summary = "学习计划列表",parameters = {
            @Parameter(name = "finishState", description = "完成状态 0未完成，1已完成", schema = @Schema(name = "finishState", type = "Long")),
            @Parameter(name = "limit", description = "分页大小", allowReserved = true, schema = @Schema(type = "int", description = "分页大小"))
            , @Parameter(name = "offset", description = "页码", allowReserved = true, schema = @Schema(type = "int", description = "页码"))})
    @GetMapping("/queryLearningList")
    public ResponseResult<Page<UserLearningListVo>> queryLearningList(HttpServletRequest request) {
        return learningPlanService.queryUserLearningPlanList(request);
    }

    @Operation(description = "学习计划详情",summary = "学习计划详情")
    @GetMapping("/queryLearningList/{learningId}")
    public ResponseResult<UserLearningPlanVo> getLearningView(@Parameter(name = "learningId", description = "计划id") @PathVariable(value = "learningId") Long learningId) {
        return learningPlanService.getUserLearningPlan(learningId);
    }

    @Operation(description = "学员参加计划记录",summary = "学员参加计划记录")
    @GetMapping("/studentJoinPlanRecord/{planId}")
    public ResponseResult studentJoinPlanRecord(@PathVariable Long planId) {
        return learningPlanService.savePlanJoinRecord(planId);
    }


}
